﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
	protected void Page_Init(object sender, EventArgs e)
	{
		// 判断用户是否已登录。
		if(HttpContext.Current.User.Identity.Name == "")
		{
			// 用户未登录。
			pnlAnonymous.Visible = true;
			pnlLoggedin.Visible = false;
		}
		else
		{
			// 用户已登录。
			pnlAnonymous.Visible = false;
			pnlLoggedin.Visible = true;

			lblUserName.Text = HttpContext.Current.User.Identity.Name;
		}
	}

    protected void Page_Load(object sender, EventArgs e)
    {
    }

	protected void btnLogin_Click(object sender, EventArgs e)
	{
		FormsAuthentication.RedirectToLoginPage();
	}
	protected void btnLogout_Click(object sender, EventArgs e)
	{
		FormsAuthentication.SignOut();
		Response.Redirect(Request.RawUrl);
	}
}
